home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1439 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.magi.com!news!news.magi.com
  2. From: nredding@magi.com (Neil Redding)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: getchar() problems!
  5. Date: Sat, 13 Jan 1996 19:24:54 -0500
  6. Organization: Magi Data Consulting
  7. Message-ID: <nredding-1301961924540001@magi04p17.magi.com>
  8. References: <DL2wFD.8BK@cdf.toronto.edu>
  9. NNTP-Posting-Host: magi04p17.magi.com
  10.  
  11. In article <DL2wFD.8BK@cdf.toronto.edu>, a228lave@cdf.toronto.edu
  12. (Laventure Derek) wrote:
  13.  
  14. >Hello!
  15. >
  16. >I am having some trouble with the following code.  All I want it to do is
  17. >read characters from the keyboard until the user types a # sign, at which point
  18. >I want to stop accepting input, and tell the user some info.  Here it is:
  19. >
  20. ...
  21. >   char ch;
  22.  
  23. >   while ((ch=getchar()) != '#')
  24.  
  25. >What _actually_ happens is the code takes characters until you hit the #, and 
  26. >then continues until you press return.  Also, the final ch=getchar(); line
  27. >appears to be ignored... it's intended as a pause.  I'm somewhat of a beginner
  28. >to the language, so any help will be greatly appreciated!
  29. >
  30. Well for one thing, getchar RETURNS AN INT  . . . NOT A CHAR.
  31.  
  32. -- 
  33. Neil Redding
  34. Ottawa, Canada
  35.